package com.ecar.api.async;

import com.ecar.api.support.util.Redis;
import com.ecar.api.support.util.SubListener;

import redis.clients.jedis.Jedis;

public class Subscriber implements Runnable {

	@Override
	public void run() {
		while (!Thread.currentThread().isInterrupted()) {
			try (Jedis jedis = Redis.getResource()) {
				jedis.subscribe(new SubListener(), "websocket.push");
			} catch (Exception e) {
				e.printStackTrace();
				if (e instanceof InterruptedException) Thread.currentThread().interrupt();
			}
		}
	}
}
